/**
 * @file   Crc16.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-20
 * @brief  Calculation of checksum with CRC-16-CCITT (polynomial is 0x1021) algorithm.
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_CRC16_CRC16_H
#define DON_CORE_CRC16_CRC16_H

#include <QtCore/qglobal.h>
#include <DON/Core/libdon-qt4-core_global.h>

namespace DON
{
namespace Core
{
namespace Crc16
{

/**
 * @brief Calculate CRC16 according to the protocol
 * @param data Binary data
 * @param startIndex Start index of the binary data from where CRC16 must be calculated
 * @param size Number of bytes to use in the calculation
 * @param[out] ok Error status output (true --> success, false --> error)
 * @return Calculated CRC16 value
 */
LIBDONQT4CORESHARED_EXPORT quint16 calculate(const QByteArray &data,
                                             const int startIndex,
                                             const int size,
                                             bool *ok = 0);

}
}
}

#endif // DON_CORE_PACKET_CRC16_H
